import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../controllers/safe_page_controller.dart';

class SafePageView extends GetView<SafePageController> {
  const SafePageView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('SafePageView'),
        centerTitle: true,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Obx(() {
              return Text("验证码返回结果:${controller.success.value}");
            }),
            ElevatedButton(
                onPressed: () async {
                  final result = await Get.toNamed('/safe-page/verify-page');
                  print("${result} =======");
                  if (result == null) {
                    debugPrint("longer 返回结果为>>> null");
                    return;
                  }
                  if (result != controller.success.value) {
                    controller.setSuccess(result as bool);
                  }
                },
                child: const Text("登录"))
          ],
        ),
      ),
    );
  }
}
